package libs.yzx.zaza;

import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

/**
 * Created by Administrator on 2016/7/22
 */
public class HandlerThreadActivity extends AppCompatActivity {


    private class MyThread extends Thread {
        private Handler handler;

        public void run() {
            Looper.prepare();
            handler = new Handler() {
                public void handleMessage(Message msg) {
                    Log.e("-->>", "" + msg.what);
                }
            };
            Looper.loop();
        }
    }


    private MyThread thread = new MyThread();

    {
        thread.start();
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


    }

    @Override
    public void onBackPressed() {
        thread.handler.sendEmptyMessage(99999999);
    }

}
